package com.longge;

import java.util.Arrays;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-23 23:32
 */
public class Bubble {

    public void sort(int[] arr){
        for (int i = arr.length-1; i >0; i--) {
            for (int j = 0; j < i; j++) {
                if (arr[j]>arr[j+1]){
                    int temp = arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {2,3,5,8,7,9,8,8,7,2,4,5};
        new Bubble().sort(arr);
        System.out.println(Arrays.toString(arr));
    }

}
